<%--
  Created by IntelliJ IDEA.
  User: de'l'l
  Date: 2021-04-13
  Time: 9:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset="UTF-8">
    <title>新增</title>
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/lib/layui/layui.js"
            charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>

</head>

<body>
<div class="x-body">
    <form class="layui-form">

        <div class="layui-form-item">
            <label for="material" class="layui-form-label">
                <span class="x-red">*</span>食材
            </label>
            <div class="layui-input-inline">
                <input type="text" id="material" name="material"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="wNumber" class="layui-form-label">
                <span class="x-red">*</span>数量
            </label>
            <div class="layui-input-inline">
                <input type="text" id="wNumber" name="wNumber"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>


        <div class="layui-form-item">
            <label for="priceone" class="layui-form-label">
                <span class="x-red">*</span>单价
            </label>
            <div class="layui-input-inline">
                <input type="text" id="priceone" name="priceone"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button type="button" class="layui-btn" onclick="materialadd()">
                增加
            </button>
        </div>
    </form>
</div>
<script>
    function materialadd() {
        var material1 = $("#material").val();
        var priceone1 = $("#priceone").val();
        var wNumber1 = $("#wNumber").val();


        $.ajax({
            url: "${pageContext.request.contextPath}/warehouse/addAjax",
            type: "get",
            data: {"material": material1, "priceone": priceone1, "wNumber": wNumber1},
            dataType: "json",

            success: function (data) {
                if (data.info == "添加成功") {
                    alert("添加成功")
                } else {
                    alert(data.info)
                }
                console.log(data.info);

                window.location.href = "${pageContext.request.contextPath}/warehouse/warehouseadd";
            }
        })
    }


</script>

</body>

</html>
